package com.jy.modules.cims.termporaryplan.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jy.modules.cims.common.controller.CimsBaseController;
import com.jy.modules.cims.common.sysUtils.SimpleStringUtils;
import com.jy.modules.cims.creditright.service.CreditRightService;
import com.jy.modules.cims.data.dto.credit.CostPlanDto;
import com.jy.platform.core.message.DataMsg;
@Controller
@Scope("prototype")
@RequestMapping("/tempCostPlan")
public class tempCostPlanController extends CimsBaseController{

	
	
	
	
	
	
	
	@Autowired
    @Qualifier("com.jy.modules.cims.creditright.service.CreditRightService")
    private CreditRightService creditRightService;
	/**
	 * 
	 * @Description 
	 * @param request
	 * @param dto
	 * @param response
	 * @param dataMsg
	 * @return   
	 * ModelAndView  
	 * @throws
	 * @author zhangmi
	 * @date 2016-3-31
	 */
	@RequestMapping(value = "/runCostPlanSql")
	@ResponseBody
    public DataMsg runCostPlanSql(HttpServletRequest request, CostPlanDto dto, HttpServletResponse response,@ModelAttribute DataMsg dataMsg){
		try {
			if(dto.getStartDate()==null){
				dataMsg.setMsg("当期还款起日不能为空！");
				return dataMsg;
			}
			if( SimpleStringUtils.hasText(dto.getCreditorCode())||
				SimpleStringUtils.hasText(dto.getTransferId())||
				SimpleStringUtils.hasText(dto.getPageNum())||
				SimpleStringUtils.hasText(dto.getDealCode())){
				creditRightService.updateThisRepaySumSql(dto);
				dataMsg.setMsg("脚本执行成功！");
			}else{
				dataMsg.setMsg("参数不正确,请认真核对参数！");
			}
		} catch (Exception e) {
			e.printStackTrace();
			dataMsg.setMsg("执行脚本异常！");
		}
        return dataMsg;
    }
}
